ALTER PUBLICATION
ALTER PUBLICATION — Change the Definition of a Publication
Synopsis
ALTER PUBLICATION name ADD TABLE [ ONLY ] table_name [ * ] [, ...]
ALTER PUBLICATION name SET TABLE [ ONLY ] table_name [ * ] [, ...]
ALTER PUBLICATION name DROP TABLE [ ONLY ] table_name [ * ] [, ...]
ALTER PUBLICATION name SET ( publication_parameter [= value] [, ... ] )
ALTER PUBLICATION name OWNER TO { new_owner | CURRENT_USER | SESSION_USER }
ALTER PUBLICATION name RENAME TO new_name
Description
The command ALTER PUBLICATION changes the attributes of a publication.
The first three sub-commands change which tables are part of the publication. SET TABLE replaces the list of tables in the publication with the specified tables. ADD TABLE and DROP TABLE add and remove one or more tables from the publication. Note that adding a table to a publication that is already subscribed to will require an ALTER SUBSCRIPTION ... REFRESH PUBLICATION action on the subscriber side to take effect.
The fourth sub-command changes all publication attributes specified in CREATE PUBLICATION. Attributes not mentioned in the command retain their previous settings. The remaining sub-commands change the owner and the name of the publication.
You must own the publication to use ALTER PUBLICATION. To change the owner, you must also be a direct or indirect member of the new owner role. The new owner must have CREATE privilege on the database. Additionally, the new owner of a FOR ALL TABLES publication must be a superuser. However, a superuser can change the ownership of a publication while bypassing these restrictions.
Parameters
name
The name of an existing publication whose definition is to be modified.
table_name
The name of an existing table. If ONLY is specified before the table name, only that table is affected. If ONLY is not specified, the table and all its descendant tables (if any) are affected. Optionally, * can be specified after the table name to explicitly indicate that descendant tables are included.
SET ( publication_parameter [= value] [, ... ] )
This clause modifies publication parameters originally set by CREATE PUBLICATION.
new_owner
The user name of the new owner of the publication.
new_name
The new name of the publication.
Examples
# Change the publication to publish only deletes and updates:
ALTER PUBLICATION noinsert SET (publish = 'update, delete');
# Add some tables to the publication:
ALTER PUBLICATION mypublication ADD TABLE users, departments;
See Also
CREATE PUBLICATION, DROP PUBLICATION, CREATE SUBSCRIPTION, ALTER SUBSCRIPTION